package com.xxdh.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.xxdh.domain.dto.LoginUserDto;
import com.xxdh.domain.po.UserExt;
import com.xxdh.mapper.UserExtMapper;
import com.xxdh.service.IUserExtService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zwg
 * @since 2024-10-15
 */
@Service
public class UserExtServiceImpl extends ServiceImpl<UserExtMapper, UserExt> implements IUserExtService {

    /**
     * 校验密码
     * @param loginUser
     * @param response
     * @return
     */
    @Override
    public boolean checkLogin(LoginUserDto loginUser, HttpServletResponse response) {
        List<UserExt> list = lambdaQuery().eq(UserExt::getUserId, Long.valueOf(loginUser.getUserId())).list();
        if(CollUtil.isEmpty(list) || !list.get(0).getPassword().equals(loginUser.getPassword())){
            return false;
        }
        return true;
    }
}
